Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

add centralized sequencer doc#59

Closed
Manav-Aggarwal wants to merge 7 commits intomainfrom
manav/centralized-sequencer-design-doc
Closed

add centralized sequencer doc#59
Manav-Aggarwal wants to merge 7 commits intomainfrom
manav/centralized-sequencer-design-doc

Conversation

@Manav-Aggarwal
Copy link
Member

Overview

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

We implement a standalone centralized sequencer that:

1. Implements the Generic Sequencer interface from the `go-sequencing` package
2. Exposes a gRPC service for rollup clients to submit transactions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt the case with execution api anymore right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, not the case once we move this code back into Rollkit

batchTime time.Duration
bq *BatchQueue
lastBatchHash []byte
seenBatches map[string]struct{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason to keep seen batches here?

Copy link
Member Author

@Manav-Aggarwal Manav-Aggarwal Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The seenBatches map is more so relevant to a verifying full node to know whether a batch was successfully published to DA or not. My understanding is this structure is equivalent to the dataCache type in Rollkit. We can get rid of it in favor of dataCache which seems like isn't currently used in Rollkit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont verify in the sequencer as well. we just pull from the queue and pass it to be executed. is there an open issue for verification?

seenBatches map[string]struct{}
seenBatchesMutex sync.RWMutex
metrics *Metrics
db *badger.DB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this to have storage?

Copy link
Member Author

@Manav-Aggarwal Manav-Aggarwal Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason to have storage currently is to keep track of the last batch hash, which is needed when a rollkit node is restarted. We can store this in Rollkit's store instead to make the centralized sequencer stateless

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, in the current design we store lots of other things, would these things be removed as well and stored in rollkit?

Copy link
Contributor

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, it would be good to understand how the sequencer can move faster than the DA layer or in tandem

Co-authored-by: Marko <marko@baricevic.me>

rollupId sequencing.RollupId // Identifier for the rollup this sequencer serves

tq *TransactionQueue // Queue for storing pending transactions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this if we fire off as soon as we get the data? also should rollkit construct batches instead of the sequencer, well they are the same thing or will be with the changes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a strong reason to have this either. Thinking that with the new changes, for a centralized sequencer setting, we should just default to the pre-separation code.

cc: @gupadhyaya

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollkit relays transactions as they gets into mempool. centralized sequencer needs a place to collect transactions and prepare batch at the batch interval (could be 1s or 2s, etc). hence the transaction queue. while the centralized sequencer and rollkit node are same but different processes, you don't want the sequencer to directly access mempool right? if you don't store it, will you create batch for every transaction? (i know with api change of submitting []Tx instead of single Tx via SubmitRollupTxs api, still you could fit in multiple sets of txs (relayed via multiple SubmitRollupTxs calls) into a single batch. queue is convenient, but open to any other ways to handle this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not work that ordering is done by the aggregator execution env and we just getTxs() and submit that? what extra ordering is there?

Comment on lines +82 to +83
lastBatchHash []byte // Hash of the last processed batch
lastBatchHashMutex sync.RWMutex // Mutex for thread-safe access to lastBatchHash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there multiple callers updating this? what is the reason for the mutex? seems expensive if there is only one updater

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get rid of mutex. only one caller (header producer of rollkit)

Comment on lines +85 to +86
seenBatches map[string]struct{} // Map to track batches that have been processed
seenBatchesMutex sync.Mutex // Mutex for thread-safe access to seenBatches
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on the mutex

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the batch producer the verifybatch is basically return true, hence you can get rid of this alltogether.

- Similar to the other methods, it first validates the rollup ID.
- It then checks if the provided batch hash exists in the internal data structure that tracks seen batches.
- If the batch hash is found, it returns a response indicating that the batch is valid. If not, it returns a response indicating that the batch is invalid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a TODO here? Currently VerifyBatch only does a quick verification of the batch hash exist in the seenBatches, however in the future, it is expected to perform the full DA verification where the batch submitted to DA as referenced using a DA height and VerifyBatch would query the DA at the referenced height to verify that the batch exists in DA.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this be what the pending header system would work off of.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending headers in rollkit is different. the verifybatch is for transaction batches.
verifyBatch for the batch producer (which is rollkit's header producer) is basically return true
for fullnodes, it needs to provide a stateless verification, meaning the verification is done using the DA


This method should be looking at the DA layer to update its view of which batches have been published.

These methods work together to ensure that the centralized sequencer can effectively manage transaction submissions, retrievals, and verifications, providing a reliable interface for rollup clients to interact with the sequencer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add something about the batch submission loop?
The centralized sequencer runs a batch submission loop at the batch timer interval which prepares a batch and submits it to DA. The batch timer is configurable.

@tac0turtle
Copy link
Contributor

closing this and bringing it into my pr, ill update it there

evstack/ev-node#2016

@tac0turtle tac0turtle closed this Mar 14, 2025
@github-project-automation github-project-automation bot moved this to Done in Evolve Mar 14, 2025
@tac0turtle tac0turtle removed this from Evolve Apr 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants